#ifndef LECTURER_LIB_H_
#define LECTURER_LIB_H_

#include "Lecturer.h"
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <sstream>

void Add_lecturer(string s, Lecturer l[], int &numberLecturer){
     string temp, a_fname, a_dob, a_addr, a_field, a_univ;
     int a_id;
     short a_LecYear;

     int mark = s.find(":");
     a_id = atoi(s.substr(0,mark).c_str());


     temp = s.substr(mark+1);
     mark = temp.find(":");
     a_fname = temp.substr(0,mark);

     temp = temp.substr(mark+1);
     mark = temp.find(":");
     a_dob = temp.substr(0,mark);

     temp = temp.substr(mark+1);
     mark = temp.find(":");
     a_addr = temp.substr(0,mark);

     temp = temp.substr(mark+1);
     mark = temp.find(":");
     a_field = temp.substr(0,mark);

     temp = temp.substr(mark+1);
     mark = temp.find(":");
     a_LecYear = atoi(temp.substr(0,mark).c_str());

     temp = temp.substr(mark+1);
     mark = temp.find(":");
     a_univ = temp.substr(0,mark);

     Lecturer lec = Lecturer::Lecturer(a_id, a_fname, a_dob, a_addr, a_field, a_LecYear, a_univ);
     l[numberLecturer] = lec;
     numberLecturer++;
}


void ReadLecturer(string _file, Lecturer l[], int &numberLecturer){
               ifstream fin;
               fin.open(_file.c_str());
               if(!fin.is_open()){
                       cout<<"Cannot open file.\n";
                       exit(1);
               }else{
                              string s = "";
                              while (getline(fin, s)){
                                Add_lecturer(s,l,numberLecturer);
                              }
                              fin.close();
               }
}

#endif
